package src;

import java.util.Scanner;

//需求：机票的价格分为淡季和旺季  ， 头等舱和经济舱收费
//按照如下规则计算机票价格：旺季（5~10月）头等舱9折 ， 经济舱 8.5折 ， 淡季（11月到来年4月）头等舱7折 ， 经济舱6.5折
public class SellingTickets {
    public static void main(String[] args) {
        double price = 0;
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入月份:" + "\t");
        int month = sc.nextInt();
        System.out.println("（头等舱为1  经济舱为0）请输入机票类型:" + "\t");
        int engine = sc.nextInt();
        System.out.println("请输入机票原价:" + "\t");
        int ticket = sc.nextInt();
        if (month >=5 && month <=10){
            price = arr(engine, ticket, 0.9, 0.85);
        } else if ((month >= 1 && month <= 4) || (month >= 11 && month <= 12)) {
            price = arr(engine, ticket, 0.7, 0.65);
        }else{
            System.out.println("输入的月份有错误");
        }
        System.out.println("机票的价格是：" + price);
    }

    public static double arr(int engine, int ticket, double x, double x1) {
        double price = 0;
        if (engine == 1) {
            price = (double) (ticket * x);
        } else if (engine == 0) {
            price = (double) (ticket * x1);
        } else {
            System.out.println("没有此类舱室");
        }
        return price;
    }
}
